package com.meihua.baoleyi.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.meihua.baoleyi.R;
import com.meihua.baoleyi.ui.AddressActivity;


/**
 * Created by liming on 2017/10/17
 */

public class BaseDeleteDialog extends Dialog implements View.OnClickListener {

    private TextView dialog_address_delete_sure;//确定
    private TextView dialog_address_delete_cencle;//取消
    private TextView message;//信息
    private AddressActivity activity;
    private int position;

    public BaseDeleteDialog(AddressActivity context, int position) {
        super(context, R.style.simple_dialog);
        activity = context;
        this.position = position;
    }

    public BaseDeleteDialog(Context context) {
        super(context, R.style.simple_dialog);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_address_delete);
        initView();
    }

    private void initView() {
        dialog_address_delete_sure = (TextView) findViewById(R.id.dialog_address_delete_sure);
        dialog_address_delete_cencle = (TextView) findViewById(R.id.dialog_address_delete_cencle);
        message = findViewById(R.id.message);

        dialog_address_delete_sure.setOnClickListener(this);
        dialog_address_delete_cencle.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.dialog_address_delete_sure://确定
//                activity.deleteAddress(position);
                dismiss();
                break;
            case R.id.dialog_address_delete_cencle://取消
                dismiss();
                break;
        }
    }

    public void setSureClick(View.OnClickListener click) {
        dialog_address_delete_sure.setOnClickListener(click);
    }

    public void setMessage(String messagestr) {
        message.setText(messagestr);
    }

    public void setSure(String surestr) {
        dialog_address_delete_sure.setText(surestr);
    }

    public void setCencle(String cenclestr, int isVisible) {
        dialog_address_delete_cencle.setText(cenclestr);
        dialog_address_delete_cencle.setVisibility(isVisible);
    }
}
